package cn.rkylin.oms.aftersale.resend.dao.impl;

import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import cn.rkylin.core.IDataBaseFactory;
import cn.rkylin.oms.aftersale.resend.dao.IAfterSaleResendSkuDAO;
import cn.rkylin.oms.aftersale.resend.domain.AfterSaleResendSku;

/**
 * 类名:AfterSaleResendSkuDAOImpl <br/>
 * 作用: 补发单明细. <br/>
 * 创建原因: 补发单明细. <br/>
 * 创建时间: 2017年11月7日 下午14:00:00 <br/>
 * 
 * @author liPeng
 * @version v1.0
 */
@Repository(value = "afterSaleResendSkuDAO")
public class AfterSaleResendSkuDAOImpl implements IAfterSaleResendSkuDAO {
    @Autowired
    IDataBaseFactory dao;

    private static final String STATEMENT_UPDATE_BY_RESENDSKUID = "updateByPrimaryKeySelectiveResendSku";
    private static final String STATEMENT_INSERT_RESENDSKU = "insertSelectiveResendSku";
    private static final String STATEMENT_SELETE_RESENDSKU_BY_RESENDSKUID = "selectByPrimaryKeyResendSku";
    private static final String STATEMENT_SELETE_RESENDSKU_BY_RESENDID = "selecResendSkuByResendId";
    private static final String STATEMENT_UPDATE_RESENDSKU_BY_RESENDID = "updateByResendID";

    /**
     * 修改补发单明细
     */
    public int updateByResendSkuIdSelective(AfterSaleResendSku record) throws Exception {
        return dao.update(STATEMENT_UPDATE_BY_RESENDSKUID, record);

    }

    public int updateByResendSkuByResend(AfterSaleResendSku record) throws Exception {
        return dao.update(STATEMENT_UPDATE_RESENDSKU_BY_RESENDID, record);

    }

    /**
     * 保存补发单明细
     */
    public int insertResendSku(AfterSaleResendSku resendSku) throws Exception {
        return dao.insert(STATEMENT_INSERT_RESENDSKU, resendSku);
    }

    /**
     * 根据补发单id查询补发单明细
     */
    public List<AfterSaleResendSku> selectResendSkubyresendId(String resendId) throws Exception {
        if (StringUtils.isBlank(resendId)) {
            return null;
        }
        AfterSaleResendSku vo = new AfterSaleResendSku();
        vo.setResendId(resendId);
        return dao.findAllList(STATEMENT_SELETE_RESENDSKU_BY_RESENDID, vo);

    }

    /**
     * 根据补发单商品id查询补发单明细
     */
    public AfterSaleResendSku selectResendSkubyresendSkuId(String resendSkuId) throws Exception {
        return dao.findOne(STATEMENT_SELETE_RESENDSKU_BY_RESENDSKUID, resendSkuId);

    }

}
